package arong.com.mvpproject.mvpPresenter;

import android.os.Handler;
import android.os.Looper;

import java.util.List;

import arong.com.mvpproject.biz.OnRequstBizIml;
import arong.com.mvpproject.biz.OnRequstListener;
import arong.com.mvpproject.mvpView.MvpView;

/**
 * Created by My on 2016/5/11.
 */
public class MvpPresenter {

    MvpView mvpView;
    OnRequstBizIml requstBizIml;
    Handler  handler;
    public MvpPresenter(MvpView mvpView){
        this.mvpView=mvpView;
        requstBizIml =new OnRequstBizIml();
        handler=new  Handler(Looper.getMainLooper());
    }
    public void  onResume(){
        mvpView.loadingView();
        requstBizIml.onResult(new OnRequstListener() {
            @Override
            public void success(final List<String> list) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        mvpView.dismissView();
                        mvpView.setListData(list);
                    }
                });

            }
            @Override
            public void failed() {
                mvpView.showMessage("发生错误");
            }
        });
    };
    public void   onItemClick(int  position){
        mvpView.showMessage("点击了："+position);
    }
}
